package com.sc.nft.dao;

import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.sc.nft.dto.UserCastCountDTO;
import com.sc.nft.entity.vo.ecology.UserExpendRecordsPageVO;
import lombok.extern.slf4j.Slf4j;
import com.sc.nft.entity.UserEcologyCastRecordsDetails;
import com.sc.nft.mapper.UserEcologyCastRecordsDetailsMapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * 生态-铸造-用户记录表-主表(sc_user_ecology_cast_records_details)数据DAO
 *
 * @author Sun
 * @since 2023-11-02 22:17:44
 * @description 由 Mybatisplus Code Generator 创建
 */
@Slf4j
@Repository
public class UserEcologyCastRecordsDetailsDao extends ServiceImpl<UserEcologyCastRecordsDetailsMapper, UserEcologyCastRecordsDetails> {

    public Page<UserExpendRecordsPageVO> expendRecordsPage(Long userId, Integer pageNo, Integer pageSize,Long creatorId) {
        return baseMapper.expendRecordsPage(new Page<>(pageNo, pageSize), userId,creatorId);
    }

    public List<UserCastCountDTO> getCountGroupUserAndCollectionId() {
        return baseMapper.getCountGroupUserAndCollectionId();
    }

    public Integer getCountByUserIdAndCollectionId(Long userId, Long collectionId) {
       return baseMapper.getCountByUserIdAndCollectionId(userId, collectionId);
    }

    public boolean updateWayConfIdByEcologyCastConfId(Long ecologyCastConfId, Long ecologyCastWayConfId) {
        LambdaUpdateWrapper<UserEcologyCastRecordsDetails> lambdaUpdateWrapper = new LambdaUpdateWrapper<>();
        lambdaUpdateWrapper.eq(UserEcologyCastRecordsDetails::getEcologyCastConfId, ecologyCastConfId);
        lambdaUpdateWrapper.set(UserEcologyCastRecordsDetails::getEcologyCastWayConfId, ecologyCastWayConfId);
        return update(lambdaUpdateWrapper);
    }
}